package com.zijidelu.luframework.plugins.tomlock.core.data;

import com.zijidelu.luframework.plugins.tomlock.core.exception.TomLockException;
import com.zijidelu.luframework.plugins.tomlock.core.handler.BaseTomLockHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Objects;

/**
 * @author ZIJIDELU
 * @datetime 2025/4/20 01:28
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class TomLockHandlerData extends TomLockData {

    /**
     * 分布式锁处理器
     */
    private Class<? extends BaseTomLockHandler> handlerClass;

    @Override
    public void validParams() {

        if (!getMethodParamsList().isEmpty() && getParamExpression().length == 0) {
            throw new TomLockException("计算处理器模式，方法参数不能为空");
        }

        if (Objects.isNull(getHandlerClass())) {
            throw new TomLockException("计算处理器模式，计算处理器类不能为空");
        }

    }

}
